package ch.bfh.abcmmh.view.detailview.streets;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JLabel;
import javax.swing.JPanel;



public class CarStreet extends JPanel {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -2628562483682102680L;
	private int width;
	private int height;
	private int numbers;
	public static int STRAITHLINE = 1;
	public static int DASHEDLINE=2;
	public static int LASTLINE=3;
	
	public CarStreet (int widht, int numbers){
	    this.numbers=numbers;
		this.width = widht;
		this.height = 30;
		this.setBackground(Color.LIGHT_GRAY);
		this.setLayout(null);
		this.setSize(width, height);
		this.setVisible(true);
		
		setUp();
		
	}
	public void setUp(){
	
	//if(numbers==1){makeStraightLine();}
	 if(numbers==2){makedashedLine();}
	//else if(numbers==3){makeStraightLine();}
	
		
	}
	
	private void makedashedLine() {
		
		int y = 1;
		int x = 0;
		while (x<width) {
			WhiteLines whiteLine = new WhiteLines();
			whiteLine.setLocation(x, y);
			add(whiteLine);
			x+=60;}
		}	
	
public void makeStraightLine(){
	this.add(new WhiteLine1());
	
}

	
private class WhiteLine1 extends JLabel{
		
		
		private static final long serialVersionUID = 1L;
		int x = width;
		int y = 4;
		private WhiteLine1(){
			Dimension dimension = new Dimension(x,y);
			this.setPreferredSize(dimension);
			this.setSize(dimension);
			this.setOpaque(true);
			this.setVisible(true);
		}
		
		public void paintComponent(Graphics g){
			Graphics2D g2 = (Graphics2D) g;
			g2.setColor(new Color(255, 255, 255));
			g2.fillRect(0, 0, x, y);}


		
										}

private class WhiteLines extends JLabel{
	
	
	private static final long serialVersionUID = 1L;
	int x = 40;
	int y = 4;
	private WhiteLines(){
		Dimension dimension = new Dimension(x,y);
		this.setPreferredSize(dimension);
		this.setSize(dimension);
		this.setOpaque(true);
		this.setVisible(true);
	}
	
	public void paintComponent(Graphics g){
		Graphics2D g2 = (Graphics2D) g;
		g2.setColor(new Color(255, 255, 255));
		g2.fillRect(0, 0, x, y);}


	
									}


	}
